def copy_properties(src):

    def _copy(dst):
        dst.__name__ = src.__name__
        dst.__doc__ = src.__doc__
        # dst.__qualname__ = src.__qualname__
        return dst
    return _copy


def decorator(func):

    @copy_properties(func)   # 这个等价于@_copy  # 而@_copy又等价于 wrapper = _copy(wrapper)
    def wrapper(*args, **kwargs):
        print("before")
        ret = func(*args, **kwargs)
        print("after")
        return ret
    return wrapper


@decorator    # add = decorator(add)
def add(x, y):
    """
    :x int
    :y int
    :return int
    """
    return x + y


if __name__ == "__main__":
    print(add.__name__, add.__doc__, add.__qualname__, sep='\n')
